package com.example.myapplication.tack_15.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.R;
import com.example.myapplication.tack_15.ConsultationActivity;
import com.example.myapplication.tack_15.LawyerQXActivity;
import com.example.myapplication.tack_15.data.ArrangeData;
import com.example.myapplication.tack_15.data.WoDeData;
import com.example.myapplication.utils.Common;
import com.example.myapplication.utils.OkHttpTool;

import java.util.List;

public class WoDeAdapter extends RecyclerView.Adapter<WoDeAdapter.My> {
    private List<WoDeData.RowsDTO> list;
    private Context context;
    private View view;
    private List<WoDeData.RowsDTO> listArrange;
    public WoDeAdapter(List<WoDeData.RowsDTO> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public My onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        view = LayoutInflater.from(context).inflate(R.layout.tack_15_wode,null);
        return new My(view);
    }

    @Override
    public void onBindViewHolder(@NonNull My holder, int position) {
        Glide.with(context).load(R.drawable.ggbond).into(holder.imags);
        holder.name.setText(list.get(position).getLawyerName());
        holder.content.setText(list.get(position).getContent());
        if("0".equals(list.get(position).getState())){
            holder.state.setText("未处理");
        }else{
            holder.state.setText("已处理");
        }
        holder.createTime.setText(list.get(position).getCreateTime());
        holder.line.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ConsultationActivity.class);
                intent.putExtra(Common.COMMON,String.valueOf(list.get(position).getId()));
                context.startActivity(intent);
            }
        });


    }

    @Override
    public int getItemCount() {
        return list != null?list.size():0;
    }

    public class My extends RecyclerView.ViewHolder{
        private ImageView imags;
        private TextView name;
        private TextView content;
        private TextView state;
        private TextView createTime;
        private LinearLayout line;
        public My(@NonNull View itemView) {
            super(itemView);
            imags = view.findViewById(R.id.imags);
            name = view.findViewById(R.id.name);
            content = view.findViewById(R.id.content);
            state = view.findViewById(R.id.state);
            createTime = view.findViewById(R.id.createTime);
            line = view.findViewById(R.id.line);
        }
    }
}
